<?php
$name = "";
    $link ="";
    $ordering = "";
    $position = "";
    $img = "";
if(isset($banner)){
    $name = $banner->name;
    $link = $banner->link;
    $ordering = $banner->ordering;
    $position = $banner->position;
    $img = $banner->image;
}
?>

<div class="" id="myModal" >
  <div class="modal-header">
    <h3 style="text-transform: capitalize;"><?php echo $action ?> banner</h3>
  </div>
<?php echo form_open_multipart('administrator/banner/index/save') ?>

<label for="cat_name">Banner name:</label><input type="text" value="<?php echo $name ?>" name="name" id="name" />
<label for="cat_name">Link:</label><input type="text" value="<?php echo $link ?>" name="link" id="link" />
            <label for="parent">Banner at:</label>
            <select name="parent_id">
                <option value="0" <?php echo $position==0?"selected=selected":""; ?> >Right side</option>
                <?php 
                
                if(count($categories)>0):?>
                    <?php foreach($categories as $cat):
                        $cat_name = $this->_global->_unserialize($cat->cat_name)
                    ?>
                        <option <?php echo $position==$cat->cat_id?"selected=selected":""; ?> value="<?php echo $cat->cat_id;?>">
                        <?php if(!empty($cat_name[$this->session->userdata('lan')])):?>
                        <?php echo $cat_name[$this->session->userdata('lan')]['title'];?></option>
                        <?php else:
                            echo 'Không tồn tại tiêu đề danh mục cho ngôn ngữ hiện tại';
                            endif;
                        ?>
                    <?php endforeach?>
                <?php endif?>
            </select>
            <label for="cat_name">Banner Image:</label><input type="file" name="userfile" />
            <img src="<?php echo base_url().$img ?>" width="150"/>
            <label for="ordering">Ordering</label>
        <input type="text" name="ordering" id="ordering" value="<?php echo $ordering ?>" />
        
        <div class="modal-footer">
    <input type="submit" class="btn btn-primary"  value="Save"/>
    <a href="<?php echo base_url().'/administrator/banner/index/'?>" class="btn">Cancel</a>
    <input type="hidden" name="action" value="<?php echo $action ?>"  id="action" />
    <input type="hidden" name="img" value="<?php echo $img ?>"  id="action" />
    <input type="hidden" name="banner_id"  value="<?php echo $banner_id ?>"/>
  </div> 
  </div>
</form>